package org.bit.createThread;

/**
 * 实现 Runnable,重写 run,使用匿名内部类
 */
public class Demo03_Create {
    public static void main(String[] args) {
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("匿名内部类创建线程...");
                }
            }
        });
        // 启动线程
        thread.start();
    }

/*    public static void main(String[] args) {
        // 匿名内部类,Runnable
        Thread thread = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    try {
                        Thread.sleep(1000);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                    System.out.println("匿名内部类,Runnable...");
                }
            }
        });
        // 启动线程
        thread.start();
    }*/
}
